//
//  XRPageMainVideoMuiTableCell.m
//  XClassRoom
//
//  Created by CoderYee on 16/11/15.
//  Copyright © 2016年 CoderYee. All rights reserved.
//

#import "XRPageMainVideoMuiTableCell.h"
@interface XRPageMainVideoMuiTableCell ()
{
    UIView    *_leftView;
    UIView    *_rightTopView;
    UIView    *_rightBottomView;
    UIView    *_bottomView;
}
@end

@implementation XRPageMainVideoMuiTableCell

-(void)addOwnView
{
    [self addleftView];
    [self addrightView];
    
    //添加分割线
    UIView  *topLineView=[[UIView alloc] init];
    [topLineView setBackgroundColor:[UIColor colorWithHexString:@"0xdddddd"]];
    [self.contentView addSubview:topLineView];
    [topLineView mas_makeConstraints:^(MASConstraintMaker *make)
     {   make.left.right.equalTo(self.contentView);
         make.height.mas_equalTo(1.0);
         make.bottom.equalTo(self.contentView.mas_centerY);
    }];
    
    UIView  *centerLineView=[[UIView alloc] init];
    [centerLineView setBackgroundColor:[UIColor colorWithHexString:@"0xdddddd"]];
    [self.contentView addSubview:centerLineView];
    [centerLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView.mas_centerY);
        make.centerX.equalTo(self.contentView);
        make.width.mas_equalTo(1.0);
    }];
    UIView  *VercenterLineView=[[UIView alloc] init];
    [VercenterLineView setBackgroundColor:[UIColor colorWithHexString:@"0xdddddd"]];
    [self.contentView addSubview:VercenterLineView];
    [VercenterLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1.0);
        make.right.equalTo(self.contentView);
        make.centerY.equalTo(_rightBottomView.mas_top);
        make.width.mas_equalTo(kMainScreenWidth*0.5);
    }];
}
#pragma mark --热门视频
-(void)addleftView
{
    
    _leftView=[[UIView alloc] init];
    [self.contentView addSubview:_leftView];
    [_leftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self.contentView);
        make.height.mas_equalTo(100);
        make.width.mas_equalTo(kMainScreenWidth*0.5);
    }];
    UILabel  *videoLable=[[UILabel alloc] init];
    videoLable.text=@"热门视频";
    [_leftView addSubview:videoLable];
    [videoLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(_leftView).with.offset(15);
        make.height.mas_equalTo(21);
    }];
    UILabel  *desvideoLable=[[UILabel alloc] init];
    desvideoLable.text=@"最好的都在这里等你!";
    desvideoLable.font=[UIFont systemFontOfSize:13];
    desvideoLable.textColor=[UIColor colorWithNSString:@"888888"];;
    [_leftView addSubview:desvideoLable];
    [desvideoLable mas_makeConstraints:^(MASConstraintMaker *make)
    {   make.top.equalTo(videoLable.mas_bottom).with.offset(0);
        make.left.equalTo(_leftView).with.offset(15);
        make.height.mas_equalTo(21);
    }];
    
//    UIImageView  *imageView=[[UIImageView alloc] init];
//    imageView.contentMode=UIViewContentModeScaleAspectFill;
//    imageView.clipsToBounds=YES;
//    [imageView setImage:[UIImage imageNamed:@"icon热门视频"]];
//    [_leftView addSubview:imageView];
//    [imageView mas_makeConstraints:^(MASConstraintMaker *make)
//     {
//        make.bottom.equalTo(_leftView).with.offset(10);
//        make.right.equalTo(_leftView).with.offset(-15);
//        make.height.mas_equalTo( 75);
//        make.width.mas_equalTo(55);
//    }];
    [_leftView bringSubviewToFront:videoLable];
    [_leftView bringSubviewToFront:desvideoLable];
    _leftView.tag=5000+0;
    UITapGestureRecognizer  *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(muiTableViewClick:)];
    [_leftView addGestureRecognizer:tap];
    
}
#pragma mark --论坛
-(void)addrightView
{
    [self addTopView];
    [self addBottomView];
}
-(void)addTopView
{
    _rightTopView=[[UIView alloc] init];
    [self.contentView addSubview:_rightTopView];
    [_rightTopView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.equalTo(self.contentView);
        make.height.mas_equalTo(55);
        make.width.mas_equalTo(kMainScreenWidth*0.5);
    }];
    UILabel  *videoLable=[[UILabel alloc] init];
    videoLable.text=@"一分答";
    [_rightTopView addSubview:videoLable];
    [videoLable mas_makeConstraints:^(MASConstraintMaker *make)
     {  make.left.top.equalTo(_rightTopView).with.offset(15);
        make.height.mas_equalTo(21);
    }];
    UILabel  *desvideoLable=[[UILabel alloc] init];
    desvideoLable.text=@"最好的都在这里等你!";
    desvideoLable.font=[UIFont systemFontOfSize:13];
    desvideoLable.textColor=[UIColor colorWithNSString:@"888888"];;
    [_rightTopView addSubview:desvideoLable];
    [desvideoLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(videoLable.mas_bottom).offset(0);
        make.left.equalTo(_rightTopView).with.offset(15);
        make.height.mas_equalTo(21);
    }];
//    UIImageView  *imageView=[[UIImageView alloc] init];
//    imageView.contentMode=UIViewContentModeScaleAspectFill;
//    imageView.clipsToBounds=YES;
//    [imageView setImage:[UIImage imageNamed:@"icon热门视频"]];
//    [_rightTopView addSubview:imageView];
//    [imageView mas_makeConstraints:^(MASConstraintMaker *make)
//     {   make.height.width.mas_equalTo(45);
//         make.right.equalTo(_rightTopView).with.offset(-15);
//         make.bottom.equalTo(_rightTopView).with.offset(10);
//    }];
    [_rightTopView bringSubviewToFront:videoLable];
    [_rightTopView bringSubviewToFront:desvideoLable];
    _rightTopView.tag=5000+1;
    UITapGestureRecognizer  *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(muiTableViewClick:)];
    [_rightTopView addGestureRecognizer:tap];
    
}
-(void)addBottomView
{
    _rightBottomView=[[UIView alloc] init];
    [self.contentView addSubview:_rightBottomView];
    [_rightBottomView mas_makeConstraints:^(MASConstraintMaker *make)
     {
        make.top.equalTo(_rightTopView.mas_bottom);
        make.bottom.equalTo(_leftView.mas_bottom);
        make.right.equalTo(self.contentView);
        make.left.equalTo(_leftView.mas_right);
    }];
    UILabel  *videoLable=[[UILabel alloc] init];
    videoLable.text=@"论坛";
    [_rightBottomView addSubview:videoLable];
    [videoLable mas_makeConstraints:^(MASConstraintMaker *make)
     {  make.left.top.equalTo(_rightBottomView).with.offset(15);
         make.height.mas_equalTo(21);
     }];
    UILabel  *desvideoLable=[[UILabel alloc] init];
    desvideoLable.text=@"最好的都在这里等你!";
    desvideoLable.font=[UIFont systemFontOfSize:13];
    desvideoLable.textColor=[UIColor colorWithNSString:@"888888"];;
    [_rightBottomView addSubview:desvideoLable];
    [desvideoLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(videoLable.mas_bottom).offset(0);
        make.left.equalTo(_rightBottomView).with.offset(15);
        make.height.mas_equalTo(21);
    }];
//    UIImageView  *imageView=[[UIImageView alloc] init];
//    imageView.contentMode=UIViewContentModeScaleAspectFill;
//    imageView.clipsToBounds=YES;
//    [imageView setImage:[UIImage imageNamed:@"icon热门视频"]];
//    [_rightBottomView addSubview:imageView];
//    [imageView mas_makeConstraints:^(MASConstraintMaker *make)
//     {   make.height.width.mas_equalTo(45);
//         make.right.equalTo(_rightBottomView).with.offset(-15);
//         make.bottom.equalTo(_rightBottomView).with.offset(10);
//     }];
    [_rightBottomView bringSubviewToFront:videoLable];
    [_rightBottomView bringSubviewToFront:desvideoLable];
    _rightBottomView.tag=5000+2;
    UITapGestureRecognizer  *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(muiTableViewClick:)];
    [_rightBottomView addGestureRecognizer:tap];
}
-(void)muiTableViewClick:(UITapGestureRecognizer *)tap
{
    if (self.delegate&&[self.delegate respondsToSelector:@selector(XRPageMainVideoMuiTableCellClickViewAtIndex:inView:)])
    {
        [self.delegate XRPageMainVideoMuiTableCellClickViewAtIndex:tap.view.tag-5000 inView:self];
    }
}
@end
